import { reqGetSearchInfo } from '@/api'

const state = {
  searchList: []
}
const mutations = {
  GETSEARCHLIST (state, searchList) {
    state.searchList = searchList
  }
}
const actions = {
  async GetSearchList ({ commit }, data = {}) {
    // 使用dispatch传递过来的
    const result = await reqGetSearchInfo(data)
    console.log(result)
    if (result.code === 200) {
      commit('GETSEARCHLIST', result.data)
    }
  }
}
// 处理数据
const getters = {
  goodsList (state) {
    return state.searchList.goodsList || undefined
  },
  attrsList (state) {
    return state.searchList.attrsList || undefined
  },
  trademarkList (state) {
    return state.searchList.trademarkList || undefined
  }
}

export default {
  // namespaced: true,
  state,
  actions,
  getters,
  mutations
}
